package filedemo;

public class Main3 {
    public static void main(String[] args) {
        try {
            java.io.BufferedWriter out1 = new java.io.BufferedWriter(new java.io.FileWriter("srcfile"));
            out1.write("string to be copied\n");
            out1.close();
            java.io.InputStream in = new java.io.FileInputStream(new java.io.File("srcfile"));
            java.io.OutputStream out = new java.io.FileOutputStream(new java.io.File("destnfile"));

            byte[] buf = new byte[1024];
            int len;
            while ((len = in.read(buf)) != -1) {
                out.write(buf, 0, len);
            }

            in.close();
            out.close();

            java.io.BufferedReader in1 = new java.io.BufferedReader(new java.io.FileReader("destnfile"));
            String str;
            while ((str = in1.readLine()) != null) {
                System.out.println(str);
            }
            in1.close();
        } catch (java.io.IOException e) {
            throw new RuntimeException(e);
        }
    }
}
